package temp;

import java.util.HashSet;
import java.util.Set;
import java.util.LinkedList;


public class TempList {
   public Temp head;
   public TempList tail;
   public TempList(Temp h, TempList t) {head=h; tail=t;}
   public TempList() {
       super();
   }

   public Set<Temp> getSet() {
           Set<Temp> result = new HashSet<Temp>();
           TempList aux = this;
           while(aux.head != null) {
                   result.add(aux.head);
                   aux = aux.tail;
           }
           return result;
   }
   public TempList(LinkedList<Temp> l) {
       head = l.get(l.size()-1);
       for(int i = l.size()-2; i > 0; i-- ){
               tail = new TempList(head, (TempList)tail);
               head = l.get(i);
       }
   }

        public String toString(){
               String rt = new String();
               for(TempList l = this; l != null; l = (TempList) l.tail ){
                       rt += l.head.toString()+ " ";
               }
               return rt;
        }

}